#!/bin/sh
basepath=$(cd `dirname $0`; pwd)
echo $basepath
cd $basepath

MASTER=yarn
NUM_EXECUTORS=12
EXECUTOR_MEMORY=5g
EXECUTOR_CORES=4
DRIVER_MEMORY=5g
PARALLELISM=100
classname=com.red.wood.task.VerificationTask
jar_url=$basepath/lib/spark-data-verification-jar-with-dependencies.jar
oracle_driver=/usr/hdp/current/spark-client/lib/ojdbc7-12.1.0.2.jar

export log_dir=$basepath/logs

if  [  -d  $log_dir ]; then 
  echo "$log_dir is exist"
else
  mkdir -p $log_dir
fi

log_time=`date -d "-1 day" +%Y%m%d`
exec_time=`date -d "-1 day" +%Y-%m-%d`

{
echo "start stat `date +"%Y-%m-%d %H:%M:%S"`"
start_exec=`date +%s`

spark-submit \
 --driver-class-path $oracle_driver \
 --queue rzx --class $classname \
 --master $MASTER \
 --num-executors $NUM_EXECUTORS \
 --executor-memory $EXECUTOR_MEMORY \
 --driver-memory $DRIVER_MEMORY \
 --executor-cores $EXECUTOR_CORES  \
 --conf spark.default.parallelism=$PARALLELISM \
$jar_url $exec_time

end_second=`date +%s`
total=$((end_second-start_exec))
echo " end exe stat a time:$total"
echo " stop: `date +"%Y-%m-%d %H:%M:%S"`"

}> ${log_dir}/day_${log_time}.log 2>&1